import { getList, addList, editList, deleteList } from '../../api/msbd-classify';

const state = {
    classifyList: []
}

const mutations = {
    GET_CLASSIFY_LIST(state, list) {
        state.classifyList = [{}, ...list]
    }
}

const actions = {
    // 请求数据列表
    async getClassifyList({ commit }) {
        let { data } = await getList()
        commit("GET_CLASSIFY_LIST", data)
    },
    // 新增数据
    async addClassifyData({ dispatch }, form) {
        console.log(form);
        await addList(form)
        dispatch("getClassifyList")
    },
    // 修改数据
    async editClassifyData({ dispatch }, form) {
        await editList(form)
        dispatch("getClassifyList")
    },
    // 删除数据
    async deleteClassifyData({ dispatch }, id) {
        await deleteList(id)
        dispatch("getClassifyList")
    }
}

const getters = {

}

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}